<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>layui在线调试</title>
    <!--<link rel="stylesheet" href="//res.layui.com/layui/dist/css/layui.css?t=1542630986927" media="all">-->
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
    <script src="/plugins/layui/layui.js"></script>
    <script src="/plugins/jquery/jquery.min.js?v=1.12.4"></script>
    <script src="/common/js/common.js"></script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>用户>增加</legend>
</fieldset>

<form class="layui-form" action="" style="margin-top: 20px;" id="form">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-inline">
                <input type="login" name="name" lay-verify="email" autocomplete="off" class="layui-input" placeholder="名称">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">登录名称</label>
            <div class="layui-input-inline">
                <input type="text" name="loginName" lay-verify="email" autocomplete="off" class="layui-input" placeholder="登录名称">
            </div>
        </div>
    </div>
    <button class="layui-btn layui-btn-normal" id="submit">默认按钮</button>
</form>
<script>
    layui.use([],function(){
        $("#submit").click(function(){
            $.post("/user/add.json",$("#form").serializeJson(),
                function(data){
                    if(data.code==200){
                        location="/user/index.html"
                        layer.msg(data.msg);
                    }else{
                        layer.msg(data.msg);
                    }
                }
            )
        })
    })
</script>
</body>
</html>
